﻿using System;
using System.Linq;

namespace HamcoWcs.Models.Monitors
{
    public abstract class ParaBase
    {
        protected int _index;
        protected abstract int _len { get; }
        public string Name { get; set; }

        protected ParaBase(int index, string name)
        {
            _index = index;
            Name = name;
        }

        protected virtual byte[] GetTargetContent(byte[] content)
            => content.Skip(_index).Take(_len).ToArray();
        public abstract void Update(byte[] content);

        protected virtual ushort Reserve(ushort t)
        {
            return (ushort)(((t & 0xff00) >> 8) | ((t & 0x00ff) << 8));
        }

        protected virtual short Reserve(short t)
        {
            return (short)(((t & 0xff00) >> 8) | ((t & 0x00ff) << 8));
        }

        public virtual int GetStart() => _index;
    }
}
